<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Util extends CI_Controller {
        public function upload(){
        $config['upload_path']      = './uploads/';
        $config['allowed_types']    = 'gif|jpg|png';
        $config['max_size']     = 0;
        $config['max_width']        = 1024;
        $config['max_height']       = 768;

        $this->load->library('upload', $config);

        if ( ! $this->upload->do_upload('file'))
        {
            $error = array('error' => $this->upload->display_errors());//可不要

           echo  $this->upload->display_errors();
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());
             $file_name=$this->upload->data('file_name');
             echo 'uploads/'.$file_name;
            //$this->load->view('upload_success', $data);
        }
    }
}


